from openpyxl import load_workbook

file_path = 'python_excel_SQL.xlsx'

wb = load_workbook(file_path)
sheet = wb.active

count = 0

for row in sheet.iter_rows(min_col=1,max_col=1, values_only=True):
    if row[0] is not None:
        count += 1
    else:
        break


for i in range(2,count+1):
    a_value = sheet[f'A{i}'].value
    b_value = sheet[f'B{i}'].value
    c_value = sheet[f'C{i}'].value
    d_value = f"UPDATE table_one SET code = REPLACE(REPLACE(code, '{a_value}', 'abcdef'), " \
              f"'{b_value}', '{c_value}' ) WHERE id = '{b_value}'"
    sheet[f'D{i}'] = d_value

wb.save(file_path)
